//
//  OTEmployeeCell.m
//  OT_OC
//
//  Created by yunmian on 2019/7/15.
//  Copyright © 2019 James. All rights reserved.
//

#import "OTEmployeeCell.h"
#import "OTEmployeeModel.h"

@interface OTEmployeeCell ()
{
    UILabel             *usernameLabel;
    UILabel             *totalTimeLabel;
    UILabel             *useTimeLabel;
    UILabel             *remainTimeLabel;
}
@end

@implementation OTEmployeeCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initUI];
    }
    return self;
}

- (void)initUI {
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    usernameLabel = [[UILabel alloc] init];
    [self.contentView addSubview:usernameLabel];
    
    totalTimeLabel = [[UILabel alloc] init];
    [self.contentView addSubview:totalTimeLabel];
    
    useTimeLabel = [[UILabel alloc] init];
    [self.contentView addSubview:useTimeLabel];
    
    remainTimeLabel = [[UILabel alloc] init];
    [self.contentView addSubview:remainTimeLabel];
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    [usernameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(-15);
        make.left.offset(10);
    }];
    
    [totalTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(-15);
        make.left.offset(100);
    }];
    
    [useTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(10);
        make.left.offset(10);
    }];
    
    [remainTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(10);
        make.left.offset(100);
    }];
}

#pragma mark Set
- (void)setEmployee:(OTEmployeeModel *)employee {
    _employee = employee;
    
    usernameLabel.text = employee.username;
    totalTimeLabel.text = [NSString stringWithFormat:@"加班：%@",employee.totalTime];
    useTimeLabel.text = [NSString stringWithFormat:@"使用：%@",employee.useTime];
    remainTimeLabel.text = [NSString stringWithFormat:@"剩余：%@",employee.remainTime];
}
@end
